package com.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.model.UserOwn;
import com.example.modelDTO.UserOwnDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

public interface UserOwnMapper extends BaseMapper<UserOwn> {
/*    @Select("SELECT product_name AS productName, COUNT(*) AS quantity, product_image AS productImage, " +
            "obtained_time AS obtainedTime, validity_period AS validityPeriod, " +
            "expiration_date AS expirationDate " +
            "FROM user_own " +
            "WHERE user_id = #{userId} AND cancelled=0" +
            "GROUP BY product_name, product_image, obtained_time, validity_period, expiration_date")
    List<UserOwnDTO> getProductCountByUserId(@Param("userId") int userId);

    @Select("SELECT user_id,COUNT(*) AS quantity FROM user_own WHERE user_id = #{userId} AND cancelled=0")
    HashMap<Integer,Integer> getCountByUserId(@Param("userId") int userId);*/

    @Select("SELECT * FROM user_own WHERE user_id=#{userId} AND cancelled=0")
    List<UserOwn> getByUserId(@Param("userId") int userId);
}
